import { commons } from '@/api'

const state = {
  sectionList: []
}

const mutations = {
  SET_SELECT_HELP_CENTER(state, data) {
    state.sectionList = data[0].tabList
  }
}

const actions = {
  getSelectSection({ commit }, params) {
    return new Promise((reslove, reject) => {
      commons
        .getTabCodeList({ params })
        .then(response => {
          const { data } = response
          commit('SET_SELECT_HELP_CENTER', data)
          reslove(data)
        })
        .catch(error => {
          reject(error)
        })
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
